Skip to main content

Creating a Behavior

You can create behaviors to customize the handling of your traffic by the CDNs. New behaviors will override the default behavior, as explained here.

To create a new behavior:

  1. Navigate to your service.
  2. Choose the Behaviors tab.
  3. Click on the Add New Behavior button.
  4. Fiil the new behavior form:
    • Name - Enter the name of the new behavior
    • Path Pattern - Wildcard expression which identifies the paths to apply the behavior on. For example, if you defined behavior for /static/*, it will apply for both /static/image.jpg and /static/example.js.
    • Actions - The list of actions to apply on the matching traffic. Click on the Add Action button to add an additional action, multiple actions can be added to a single behavior.
  5. Click on Save.

Order of Applying Behavior

Behaviors are applied on the traffic in a multi match approach, i.e. if a request matches multiple behaviors, they will all be applied on it. The order of applying multiple behaviors on a given request is determined by the path hierarchy of the path patterns. The default behavior which applies for all of the traffic is applied first, and more specific path patterns are applied later according to hierarchy.

Example:

  • Behavior B1 - path pattern /a/*
  • Behavior B2 - path pattern /b/*
  • Behavior B3 - path pattern /a/c/*

Giver a request for /a/c/example.html, the following behaviors will be applied by this order:

  1. Default behavior
  2. Behavior B1
  3. Behavior B3

Overriding Behaviors

Since multiple behaviors can be applied on a single request, these behaviors can override one another. For example, if behavior A defines cache TTL of 60 seconds, and behavior B defines cache TTL of 120 seconds, which one will be applied? In case 2 matching behaviors are applied to the same request, the more specific behavior will take precedence over the other. In the previous example, if behavior A is applied on /a/*, behavior B is applied for /a/b/*, and the request is for /a/b/example.html, then behavior B will take precedence over behavior A.

Conflicting Paths

As mentioned above, multiple behaviors can be created within a single service. Each behavior is identified by a path pattern. You cannot create behaviors with a conflicting path pattern. Two path patterns are considered to be conflicting if the intersection between them is not empty and it is not equal to any of the paths.

Example 1:

  • Path A - /a/*
  • Path B - /b/*

The paths above are not conflicting since the intersection between them is empty.

Example 2:

  • Path A - /a/*
  • Path B - /a/b/*

The paths above are not conflicting. The intersection between them is not empty, however, the intersection is equal to path B.

Example 3:

  • Path A - /a/*
  • Path B - *.js

The paths above are conflicting. The intersection between them is not empty, and it is not equal to any of them. For example, the object /a/example.js matches both path patterns.